package com.vsen.lpr.controller;


import com.vsen.lpr.common.model.Response;
import com.vsen.lpr.entity.OrderDetail;
import com.vsen.lpr.pojo.dto.OrderListDto;
import com.vsen.lpr.pojo.dto.PlaceOrderDto;
import com.vsen.lpr.pojo.vo.OrderListVo;
import com.vsen.lpr.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;


    /**
     * 下单
     *
     * @return
     */
    @PostMapping("/placeOrder")
    @ResponseBody
    Response placeOrder(@RequestBody PlaceOrderDto placeOrderDto) {
        return orderService.placeOrder(placeOrderDto);
    }


    /**
     * 用户历史订单
     *
     * @return
     */
    @PostMapping("/orderList")
    @ResponseBody
    Response<List<OrderListVo>> orderList(@RequestBody OrderListDto orderListDto) {
        return orderService.orderList(orderListDto);
    }
}
